package com.zhaoxi.project.wms.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhaoxi.framework.aspectj.lang.annotation.Log;
import com.zhaoxi.framework.aspectj.lang.enums.BusinessType;
import com.zhaoxi.project.wms.domain.MesRoute;
import com.zhaoxi.project.wms.service.impl.MesRouteServiceImpl;
import com.zhaoxi.framework.web.BaseService;
import com.zhaoxi.framework.web.PageData;
import com.zhaoxi.common.utils.poi.ExcelUtil;
import com.zhaoxi.framework.web.page.TableDataInfo;

/**
 * 工艺路线Controller
 *
 * @author zhaoxi
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/mes/route")
public class MesRouteController extends BaseService
{
    @Autowired
    private MesRouteServiceImpl mesRouteService;

    /**
     * 查询工艺路线列表
     */
    @PreAuthorize("@ss.hasPermi('wms:route:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesRoute mesRoute)
    {
        startPage();
        List<MesRoute> list = mesRouteService.selectMesRouteList(mesRoute);
        return getDataTable(list);
    }

    /**
     * 导出工艺路线列表
     */
    @PreAuthorize("@ss.hasPermi('wms:route:export')")
    @Log(title = "工艺路线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesRoute mesRoute)
    {
        List<MesRoute> list = mesRouteService.selectMesRouteList(mesRoute);
        ExcelUtil<MesRoute> util = new ExcelUtil<MesRoute>(MesRoute.class);
        util.exportExcel(response, list, "工艺路线数据");
    }

    /**
     * 获取工艺路线详细信息
     */
    @PreAuthorize("@ss.hasPermi('wms:route:query')")
    @GetMapping(value = "/{id}")
    public PageData getInfo(@PathVariable("id") Long id)
    {
        return success(mesRouteService.selectMesRouteById(id));
    }

    /**
     * 新增工艺路线
     */
    @PreAuthorize("@ss.hasPermi('wms:route:add')")
    @Log(title = "工艺路线", businessType = BusinessType.INSERT)
    @PostMapping
    public PageData add(@RequestBody MesRoute mesRoute)
    {
        return toAjax(mesRouteService.insertMesRoute(mesRoute));
    }

    /**
     * 修改工艺路线
     */
    @PreAuthorize("@ss.hasPermi('wms:route:edit')")
    @Log(title = "工艺路线", businessType = BusinessType.UPDATE)
    @PutMapping
    public PageData edit(@RequestBody MesRoute mesRoute)
    {
        return toAjax(mesRouteService.updateMesRoute(mesRoute));
    }

    /**
     * 删除工艺路线
     */
    @PreAuthorize("@ss.hasPermi('wms:route:remove')")
    @Log(title = "工艺路线", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public PageData remove(@PathVariable Long[] ids)
    {
        return toAjax(mesRouteService.deleteMesRouteByIds(ids));
    }
}
